﻿using ReflectionStudio.Components.UserControls;
using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using WPFExcelReport.Helpers;
using System.Windows.Controls;
using System.Collections.Generic;
namespace WPFExcelReport
{
    public partial class UIVKKOPF : ViewBase
    {

        public UIVKKOPF()
        {

        }

        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            base.Window_Loaded(sender, e);
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            dwVKK = dwMaster;
            IsInactive = false;
            if (dwMaster == null)
            {
                SACHBE = app.User;
                KUNDNR = "";
                LIEFBED = "";
                KDSTA = " ";
                VG = "";
                ZAHLBED = "";
                AUF = "";
                AUFART = "";
                VSPED = "".PadRight(3);
                SART = "".PadRight(3);
                TXTISIND = "";
                IsAUFConfirmed = false;
                KURS = "0000000";
                KD06KEY = "";
                VKKANSPRECH = "";
                VKZAHLBED = "";
                VKKHWAEHRSL = "   ";
            }
            else
            {
                KEY = TMV.VKKAUFKRS + TMV.VKKAUFLFD + "000" + KUNDNR + "K";
                AUF = "K" + TMV.VKKAUFKRS + TMV.VKKAUFLFD + "000" + KUNDNR + LIEFSCH.PadRight(8);
                TXTISIND = (TMV.VKKAUFKRS + TMV.VKKAUFLFD + "000" + "VKT").PadRight(60);
                if (TMV.VKKSA == "IN")
                    IsInactive = true;
                AUFART = TMV.VKKAUFART;
                KDSTA = TMV.VKKKDSTA;
                SACHBE = TMV.VKKSACHBE;
                KUNDNR = TMV.VKKKUNDNR;
                ZAHLBED = TMV.VKKZAHLBED.PadRight(3);
                KURS = TMV.VKKKURS;
                VB = TMV.VKKVB;
                VG = TMV.VKKVG;
                LIEFBED = TMV.VKKLIEFBED;
                AUFART = TMV.VKKAUFART;
                SART = TMV.VKKVERSART.PadRight(3);
                VSPED = TMV.VKKSPED.PadRight(3);
                VKKANSPRECH = TMV.VKKANSPRECH;
                if (IsInactive)
                    return;
                KD06KEY = KUNDNR + "   " + TMV.VKKVG;

                if (dwMaster["VKKGESSTA"].ToString().Trim().Length == 0)
                    dwMaster["VKKGESSTA"] = 10;
                if (Convert.ToInt16(dwMaster["VKKGESSTA"].ToString()) > 10)
                    IsAUFConfirmed = true;
            }
        }
        public void VKKConfonfirm(object sender, RoutedEventArgs e)
        {

            switch (app.company)
            {
                default:
                case "SXN":
                case "TST":
                    TSTVKKCOM();
                    break;
                case "UBT":
                    UBTVKKCOM();
                    QueryCommand(null, null);
                    break;
                case "JLT":
                    JLTVKKCOM();
                    break;
            }
            PM["CUSER"] = app.User;
            PM["EVENTID"] = "MVK04";
            PM["dwInput"] = dwMaster;
            PM["KRS"] = dwMaster["VKKAUFKRS"];
            PM["LFD"] = dwMaster["VKKAUFLFD"];
            PM["POS"] = "000";
            PM["MSG"] = new MessageInfo();
            PM["INFO"] = Helpers.Helper.ConvertGB2312To8859P1("销售单录入完成");
            WFNEW = null;
            WFNEW = PM;
        }
        public override void OnWFNEWChg(Dictionary<string, object> pm)
        {

            base.OnWFNEWChg(pm);
        }

        public void JLTVKKCOM()
        {
            try
            {

                if (dwMaster == null)
                    return;
                IsAUFConfirmed = true;
                PM["KRS"] = dwMaster["VKKAUFKRS"];
                PM["LFD"] = dwMaster["VKKAUFLFD"];
                PM["AUFTYP"] = "K";
                string temp = "";
                switch (AUFART)
                {
                    default:
                        break;
                    case "BO":
                    case "NA":
                    case "SM":
                    case "TW":
                        //TMV.VKP.LOCKVKPOS(PM);
                        //TMV.VWD.WDNEWBYVKK(PM);//若需采购，则在这里进行
                        TMV.CHECKVKKVR(dwMaster, RENR);
                        /*
                        dwMaster["VKKAUFSTA"] = "21";//20是初始值
                        dwMaster["VKKGESSTA"] = "11";//10是初始值   
                        TMV.UpdateVKKOPF(dwMaster, app.company, 0);*/
                        VICC_WFEVENTS.SVWF.VR02(RUNID, AUF);
                        break;

                }

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public void TSTVKKCOM()
        {
            try
            {

                if (dwMaster == null)
                    return;
                IsAUFConfirmed = true;
                PM["KRS"] = dwMaster["VKKAUFKRS"];
                PM["LFD"] = dwMaster["VKKAUFLFD"];
                PM["AUFTYP"] = "K";
                PM["LIEFNR"] = LIEFNR;
                TMV.VKP.REMOVE0QTY(PM);
                string temp = "";
                switch (AUFART)
                {
                    default:
                        dwMaster["VKKAUFSTA"] = "20";//20是初始值
                        TMV.UpdateVKKOPF(dwMaster, app.company, 0);
                        break;
                    case "BO":
                    case "NA":
                    case "SM":
                    case "TW":
                        TMV.VKP.LOCKVKPOS(PM);
                        TMV.VWD.WDNEWBYVKK(PM);//若需采购，则在这里进行
                        TMV.CHECKVKKVR(dwMaster, RENR);
                        dwMaster["VKKAUFSTA"] = "21";//20是初始值
                        dwMaster["VKKGESSTA"] = "11";//10是初始值   
                        TMV.UpdateVKKOPF(dwMaster, app.company, 0);
                        VICC_WFEVENTS.SVWF.VR02(RUNID, AUF);
                        break;
                    case "KS"://客户自己采购                        
                        TMV.VWD.WDNEWBYVKK(PM);//若需采购，则在这里进行 
                        dwMaster["VKKAUFSTA"] = "20";//20是初始值
                        TMV.UpdateVKKOPF(dwMaster, app.company, 0);
                        IsAutoEK = false;
                        IsAutoEK = true;
                        temp = AUF;
                        AUF = "";
                        AUF = temp;
                        IsAutoEK = false;
                        VICC_WFEVENTS.SVWF.EK02(RUNID, EKAUF);
                        break;
                    case "DS"://待收付染色款，比如                        
                        TMV.VWD.WDNEWBYVKK(PM);//若需采购，则在这里进行 
                        dwMaster["VKKAUFSTA"] = "20";//20是初始值
                        TMV.CHECKVKKVR(dwMaster, RENR);
                        dwMaster["VKKAUFSTA"] = "21";//20是初始值
                        dwMaster["VKKGESSTA"] = "11";//10是初始值  
                        TMV.UpdateVKKOPF(dwMaster, app.company, 0);
                        VICC_WFEVENTS.SVWF.VR02(RUNID, AUF);
                        IsAutoEK = false;
                        IsAutoEK = true;
                        temp = AUF;
                        AUF = "";
                        AUF = temp;
                        IsAutoEK = false;
                        VICC_WFEVENTS.SVWF.EK02(RUNID, EKAUF);
                        break;
                }

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public void UBTVKKCOM()
        {
            try
            {

                if (dwMaster == null)
                    return;
                IsAUFConfirmed = true;
                PM["KRS"] = dwMaster["VKKAUFKRS"];
                PM["LFD"] = dwMaster["VKKAUFLFD"];
                PM["AUFTYP"] = "K";
                TMV.VKP.REMOVE0QTY(PM);
                string temp = "";
                switch (AUFART)
                {
                    default:
                        dwMaster["VKKAUFSTA"] = "20";//20是初始值
                        TMV.UpdateVKKOPF(dwMaster, app.company, 0);
                        break;
                    case "BO":
                    case "NA":
                    case "SM":
                    case "TW":
                        TMV.VKP.LOCKVKPOS(PM);
                        TMV.VWD.WDNEWBYVKK(PM);//若需采购，则在这里进行
                        TMV.CHECKVKKVR(dwMaster, RENR);
                        dwMaster["VKKAUFSTA"] = "21";//20是初始值
                        dwMaster["VKKGESSTA"] = "11";//10是初始值   
                        TMV.UpdateVKKOPF(dwMaster, app.company, 0);
                        // VICC_WFEVENTS.SVWF.VR02(RUNID, AUF);
                        break;
                    case "KS"://客户自己采购
                        TMV.VWD.WDNEWBYVKK(PM);//若需采购，则在这里进行 
                        dwMaster["VKKAUFSTA"] = "20";//20是初始值
                        TMV.UpdateVKKOPF(dwMaster, app.company, 0);
                        IsAutoEK = false;
                        IsAutoEK = true;
                        temp = AUF;
                        AUF = "";
                        AUF = temp;
                        IsAutoEK = false;
                        //VICC_WFEVENTS.SVWF.EK02(RUNID, "B" + EKAUF);
                        break;
                }

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public virtual void OnWERTChg()
        {
            if (dwMaster == null)
                return;
            dwData = TBMain.NewRow();
            dwData.ItemArray = dwMaster.ItemArray;
            dwData["VKKSACHBE"] = " AND VKKSACHBE='" + dwMaster["VKKSACHBE"].ToString() + "'";
            SResult = TMV.QueryVKKOPF(dwData, 1);
            foreach (DataRow row in SResult.Tables[0].Rows)
            {
                dwMaster["VKKGESWERT"] = row["VKKGESWERT"];
                dwMaster["VKKGESMENGE1"] = row["VKKGESMENGE1"];
                dwMaster["VKKGESMENGE2"] = row["VKKGESMENGE2"];
                dwMaster["VKKGESMENGE3"] = row["VKKGESMENGE3"];
                dwMaster["VKKGESMENGE4"] = row["VKKGESMENGE4"];
            }
        }

        public override void New()
        {
            if (!IsNew)
            {
                IsNew = true;
                TBMain.Clear();
                OnAppModeChg();
                return;
            }
            if (VKKHWAEHRSL.Trim().Length == 0)
            {
                VKKHWAEHRSL = app.WAEHRSL;
                return;
            }
            if (KUNDNR.Trim().Length < 6)
            {
                MessageBox.Show("请先输入客户,然后重试");
                return;
            }
            if (KRS.Trim().Length < 2)
            {
                MessageBox.Show("必须输入两位长度的前缀");
                return;
            }
            if (VKZAHLBED.Trim().Length < 3)
            {
                MessageBox.Show("必须输入付款方式");
                return;
            }
            if (VB.Trim().Length < 2)
            {
                MessageBox.Show("必须选择分组");
                return;
            }

            dwData = TBMain.NewRow();
            TMV.SetUpNewRow(ref dwData);
            dwData["VKKMANDANT"] = app.Mandant;
            dwData["VKKAUFART"] = AUFART.PadRight(2);
            dwData["VKKSA"] = "  ";

            LFD = VSDDAT.SD22.GETNEXT("0022", KRS, "VKAUFTR");
            dwData["VKKKUNDNR"] = KUNDNR;
            dwData["VKKAUFKRS"] = KRS;
            dwData["VKKAUFLFD"] = LFD;
            dwData["VKKVB"] = VB.PadRight(3);
            dwData["VKKVG"] = VG.PadRight(3);
            dwData["VKKZAHLBED"] = VKZAHLBED.PadRight(3);
            dwData["VKKSACHBE"] = SACHBE;
            dwData["VKKKURS"] = KURS;
            dwData["VKKHWAEHRSL"] = VKKHWAEHRSL;
            dwData["VKKKURS"] = KURS;
            dwData["VKKWAEHRSL"] = app.WAEHRSL;//评估价格 
            dwData["VKKKREDKDNR"] = dwData["VKKKUNDNR"];
            dwData["VKKKDARTBEZ"] = "K";
            dwData["VKKBESTDAT"] = dwData["VKKNEUDAT"];
            dwData["VKKAEDAT"] = dwData["VKKNEUDAT"];
            dwData["VKKBSTDAT"] = dwData["VKKNEUDAT"];
            Insert(dwData);
            IsNew = false;
        }

        public void Insert(DataRow _dwVKK)
        {
            TMV.InsertVKKOPF(_dwVKK, app.company);
            TBMain.Rows.InsertAt(_dwVKK, 0);
            vwMaster.View.MoveCurrentToFirst();
        }

        public virtual void Load()
        {
        }

        public void KURS_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (!IsEdit)
                return;

            if (e.Key != System.Windows.Input.Key.Enter)
                return;
            if (e.Key != System.Windows.Input.Key.Return)
                return;
            this.Focus();
            TextBox tb = sender as TextBox;
            tb.Focus();
        }

        public override void NewCommand(object sender, System.Windows.RoutedEventArgs e)
        {
            try
            {
                LFD = "";
                New();
                base.NewCommand(sender, e);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        public override void DeleteCommand(object sender, System.Windows.RoutedEventArgs e)
        {
            if (dwMaster == null)
                return;
            TMV.DeleteVKKOPF(dwMaster, 1);

            vwMaster.View.MoveCurrentTo(-1);
            string filter = "VKKAUFKRS='" + dwMaster["VKKAUFKRS"].ToString() + "' AND VKKAUFLFD='" + dwMaster["VKKAUFLFD"].ToString() + "'";
            DataRow[] rows = TBMain.Select(filter);
            foreach (DataRow row in rows)
            {
                row.Delete();
            }
            TBMain.AcceptChanges();
            base.DeleteCommand(sender, e);
        }
        public override void SaveCommand(object sender, RoutedEventArgs e)
        {
            try
            {
                Update();
                base.SaveCommand(sender, e);
                //QueryCommand(null,null);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        public override void Update()
        {
            if (dwMaster == null)
                return;
            TMV.UpdateVKKOPF(dwMaster, app.company, 0);
            TMV.MANAGEVKP(dwMaster);
            TMV.DVKK02(dwMaster);
        }

        public virtual void CheckEnv(string _aufart)
        {
            switch (_aufart)
            {
                case "DS":
                    IsCheckKD = true;
                    IsAutoVRK = true;
                    IsCheckLS = true;
                    break;
                case "KS":
                    IsCheckKD = true;
                    IsAutoVRK = false;
                    IsCheckLS = false;
                    break;
                case "NA":
                    IsCheckKD = true;
                    IsAutoVRK = true;
                    IsCheckLS = false;
                    break;
                case "CO":
                    IsCheckKD = true;
                    IsAutoVRK = false;
                    IsCheckLS = false;
                    break;
                case "OF":
                    IsCheckKD = false;
                    IsAutoVRK = false;
                    IsCheckLS = false;
                    break;
                case "SM":
                    IsCheckKD = false;
                    IsAutoVRK = true;
                    IsCheckLS = false;
                    break;
                case "TW":
                    IsCheckKD = true;
                    IsAutoVRK = true;
                    IsCheckLS = false;
                    break;
                default:
                    IsCheckKD = true;
                    IsAutoVRK = false;
                    IsCheckLS = false;
                    break;
            }

        }


        public override void EditCommand(object sender, System.Windows.RoutedEventArgs e)
        {
            base.EditCommand(sender, e);
        }

        public void AUF_Enter(object sender, System.Windows.Input.KeyEventArgs e)
        {
            if (e.Key != System.Windows.Input.Key.Enter)
                return;
            if (e.Key != System.Windows.Input.Key.Return)
                return;
            this.Focus();
            QueryCommand(sender, e);
        }

        public override void ManageCommand(object sender, RoutedEventArgs e)
        {
            TMV.VK02();
        }

        public void LinkedOrderCommand(object sender, RoutedEventArgs e)
        {
            VICC_WFEVENTS.SVWF.EK02(this.RUNID, "K" + KEY);
        }

        public void OnKDBLOCKChg(bool value)
        {
            if (value)
            {
                KDSTA = "KD";//因为信用锁定
            }
        }

        public virtual void OnSACHBEChg(string value)
        {
            if (!IsEdit)
                return;
            if (dwMaster == null)
                return;
            dwData = TMV.VKP.TBMain.NewRow();
            dwData["VKPMANDANT"] = app.Mandant;
            dwData["VKPAUFKRS"] = dwMaster["VKKAUFKRS"];
            dwData["VKPAUFLFD"] = dwMaster["VKKAUFLFD"];
            dwData["VKPSACHBE"] = dwMaster["VKKSACHBE"];
            TMV.VKP.UpdateVKPOS(dwData, app.company, 18);
            OnVBChg(VB);
        }

        public virtual void OnSARTChg(string value)
        {
            if (!IsEdit)
                return;
            if (dwMaster == null)
                return;
            TMV.VKKVERSART = value;
        }

        public virtual void OnVSPEDChg(string value)
        {
            if (!IsEdit)
                return;
            if (dwMaster == null)
                return;
            TMV.VKKSPED = value;
        }

        public virtual void OnAUFChg(string value)
        {

        }

        public void OnIsAUFConfirmedChg(bool value)
        {
        }

        public override void OnAppModeChg()
        {
            base.OnAppModeChg();

            switch (app.company)
            {
                case "TST":
                    switch (app.AppMode)
                    {
                        case "TISSUE":
                            KRS = MV.year.Substring(2, 2);
                            // KRS = "S" + MV.year.Substring(3, 1);
                            VB = "TSK";
                            break;
                        case "TMODE":
                            KRS = MV.year.Substring(2, 2);
                            // KRS = "M" + MV.year.Substring(3, 1);
                            VB = "TMK";
                            break;

                    }
                    break;
                case "SJH":
                    KRS = MV.year.Substring(2, 2);
                    VB = "NX ".PadRight(3);
                    break;
                case "JLT":
                    KRS = "J" + MV.year.Substring(3, 1);
                    VB = app.company.PadRight(3);
                    break;
                default:
                    KRS = MV.year.Substring(2, 2);
                    VB = app.company.PadRight(3);
                    break;
            }
        }

        public override void SetUpUserRight()
        {
            base.SetUpUserRight();
            Type mom = this.GetType();
            if (mom == null)
                return;
            string filter = "USERID='" + app.User + "' AND PROG='" + mom.Name.PadRight(80) + "'";
            DataRow[] rows = TBUR.Select(filter);
            foreach (DataRow row in rows)
            {
                string contol = row["CONTROLS"].ToString();//属性 
                string PROCESS = row["PROCESS"].ToString();//控制值
                string txt = row["P0"].ToString();//文本值 
                bool blControl = true;
                if (PROCESS.Trim() == "N")
                {
                    blControl = false; ;
                }
                if (PROCESS.Trim() == "Y")
                {
                    blControl = true; ;
                }
                switch (contol.Trim())
                {
                    case "CHGZA":
                        IsChgZA = blControl;
                        break;
                }
            }
        }

        public void VRManagement(object sender, RoutedEventArgs e)
        {
            VICC_WFEVENTS.SVWF.VR02(RUNID, AUF);
        }

        public virtual void OnKUNDNRBYChg(string value)
        {
        }

        public virtual void OnVKKSAChg(string value)
        {
        }

        public virtual void OnKURSChg(string value)
        {
            if (!IsEdit)
                return;
            if (dwMaster == null)
                return;
            TMV.VKKKURS = Helper.Right("0000000" + Helper.RoundX(Convert.ToDouble(value), 1), 7);

        }

        public virtual void OnZAHLBEDChg(string value)
        {
            if (!IsEdit)
                return;

            //TMV.VKKZAHLBED = value.PadRight(3);

        }

        public override void InactiveCommand(object sender, RoutedEventArgs e)
        {
            if (dwMaster == null)
                return;
            if (app.User.Trim() != "TSTV")
            {
                MessageBox.Show("只有指定用户，才可以屏蔽订单");
                return;
            }

            dwMaster["VKKSA"] = "IN";
            TMV.UpdateVKKOPF(dwMaster, app.company, 20);
            dwData = TMV.VKP.TBMain.NewRow();
            dwData["VKPMANDANT"] = app.Mandant;
            dwData["VKPSA"] = "IN";
            dwData["VKPAUFKRS"] = dwMaster["VKKAUFKRS"];
            dwData["VKPAUFLFD"] = dwMaster["VKKAUFLFD"];
            TMV.VKP.UpdateVKPOS(dwData, app.company, 20);

            dwData = TMV.VZB.TBMain.NewRow();
            dwData["VKZMANDANT"] = app.Mandant;
            dwData["VKZSA"] = "VK";
            dwData["VKZAUFKRS"] = dwMaster["VKKAUFKRS"];
            dwData["VKZAUFLFD"] = dwMaster["VKKAUFLFD"];
            TMV.VZB.UpdateVKZUAB(dwData, app.company, 20);// 无任何该动

            dwData = TMV.MUX.TBMain.NewRow();
            dwData["ABAMANDANT"] = app.Mandant;
            dwData["ABAVKAUFKRS"] = dwMaster["VKKAUFKRS"];
            dwData["ABAVKAUFLFD"] = dwMaster["VKKAUFLFD"];
            TMV.MUX.DeleteABAUFM(dwData, 20);

            dwData = TMV.VKD.TBMain.NewRow();
            dwData["VKAMANDANT"] = app.Mandant;
            dwData["VKAAUFKRS"] = dwMaster["VKKAUFKRS"];
            dwData["VKAAUFLFD"] = dwMaster["VKKAUFLFD"];
            dwData["VKASA"] = " ";
            TMV.VKD.DeleteVKADR(dwData, 0);

            dwData = TMV.VWD.TBMain.NewRow();
            dwData["WDMANDANT"] = app.Mandant;
            dwData["WDAUFKRS"] = dwMaster["VKKAUFKRS"];
            dwData["WDAUFLFD"] = dwMaster["VKKAUFLFD"];
            dwData["WDSA"] = "K";
            TMV.VWD.DeleteWDECK(dwData, 20);
            UpdateVK04(dwMaster["VKKAUFKRS"].ToString() + dwMaster["VKKAUFLFD"].ToString());
            base.InactiveCommand(sender, e);
        }

        private void UpdateVK04(string order)
        {
            dwData = TBMain.NewRow();
            dwData["VKKMANDANT"] = app.Mandant;
            dwData["VKKAUFKRS"] = order.Substring(0, 2);
            dwData["VKKAUFLFD"] = order.Substring(2, 6);
            TMV.UpdateVKKOPF(dwData, app.company, 5);
        }

        public override void LOADBYAUF()
        {
            if (!IsCanLoad)
                return;
            if (!IsLoaded)
                return;
            TBMain.Clear();
            if (ORDERNUM == "")
                return;
            dwData = TBMain.NewRow();
            KRS = ORDERNUM.Substring(1, 2);
            LFD = ORDERNUM.Substring(3, 6);
            PM["KRS"] = ORDERNUM.Substring(1, 2);
            PM["LFD"] = ORDERNUM.Substring(3, 6);
            MergeData(TMV.VKKLOAD(PM));
            base.LOADBYAUF();
        }
        public virtual void OnEVKKChgApp(bool value)
        {
            if (!value)
                return;
            if (dwMaster == null)
                return;
            dwMaster["VKKAUFSTA"] = "20";//20是初始值
            TMV.UpdateVKKOPF(dwMaster, app.company, 0);
            IsAUFConfirmed = false;
        }
    }
    public partial class UIVKKOPF
    {
        public VVKKOPF TMV
        {
            get
            {
                return (VVKKOPF)MV;
            }
        }
        #region ==IsMTR===========
        public static readonly DependencyProperty IsMTRProperty = DependencyProperty.Register("IsMTR",
            typeof(bool), typeof(UIVKKOPF),
            new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsMTRChanged));
        public bool IsMTR
        {
            get
            {
                return (bool)GetValue(IsMTRProperty);
            }
            set
            {
                SetValue(IsMTRProperty, value);
            }
        }
        private static void OnIsMTRChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.IsMTR = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsKG===========
        public static readonly DependencyProperty IsKGProperty = DependencyProperty.Register("IsKG",
            typeof(bool), typeof(UIVKKOPF),
            new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsKGChanged));
        public bool IsKG
        {
            get
            {
                return (bool)GetValue(IsKGProperty);
            }
            set
            {
                SetValue(IsKGProperty, value);
            }
        }
        private static void OnIsKGChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.IsKG = (bool)e.NewValue;
            }
        }
        #endregion
        #region ==VKKSA===========
        public static readonly DependencyProperty VKKSAProperty = DependencyProperty.Register("VKKSA",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVKKSAChanged));
        public string VKKSA
        {
            get
            {
                return (string)GetValue(VKKSAProperty);
            }
            set
            {
                SetValue(VKKSAProperty, value);
                OnVKKSAChg(value);
            }
        }
        private static void OnVKKSAChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.VKKSA = (string)e.NewValue;
            }
        }
        #endregion

        #region ==KUNDNRBY===========
        public static readonly DependencyProperty KUNDNRBYProperty = DependencyProperty.Register("KUNDNRBY",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnKUNDNRBYChanged));
        public string KUNDNRBY
        {
            get
            {
                return (string)GetValue(KUNDNRBYProperty);
            }
            set
            {
                SetValue(KUNDNRBYProperty, value);
                OnKUNDNRBYChg(value);
            }
        }
        private static void OnKUNDNRBYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.KUNDNRBY = (string)e.NewValue;
            }
        }
        #endregion

        #region ==IsAutoVRK===========
        public static readonly DependencyProperty IsAutoVRKProperty = DependencyProperty.Register("IsAutoVRK",
        typeof(bool), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsAutoVRKChanged));
        public bool IsAutoVRK
        {
            get
            {
                return (bool)GetValue(IsAutoVRKProperty);
            }
            set
            {
                SetValue(IsAutoVRKProperty, value);
            }
        }
        private static void OnIsAutoVRKChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.IsAutoVRK = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsAutoEK===========
        public static readonly DependencyProperty IsAutoEKProperty = DependencyProperty.Register("IsAutoEK",
        typeof(bool), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsAutoEKChanged));
        public bool IsAutoEK
        {
            get
            {
                return (bool)GetValue(IsAutoEKProperty);
            }
            set
            {
                SetValue(IsAutoEKProperty, value);
            }
        }
        private static void OnIsAutoEKChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.IsAutoEK = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==EKAUF===========
        public static readonly DependencyProperty EKAUFProperty = DependencyProperty.Register("EKAUF",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnEKAUFChanged));
        public string EKAUF
        {
            get
            {
                return (string)GetValue(EKAUFProperty);
            }
            set
            {
                SetValue(EKAUFProperty, value);
            }
        }
        private static void OnEKAUFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.EKAUF = (string)e.NewValue;
            }
        }
        #endregion

        #region ==RENR===========
        public static readonly DependencyProperty RENRProperty = DependencyProperty.Register("RENR",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnRENRChanged));
        public string RENR
        {
            get
            {
                return (string)GetValue(RENRProperty);
            }
            set
            {
                SetValue(RENRProperty, value);
            }
        }
        private static void OnRENRChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.RENR = (string)e.NewValue;
            }
        }
        #endregion

        #region ==IsChgZA===========
        public static readonly DependencyProperty IsChgZAProperty = DependencyProperty.Register("IsChgZA",
        typeof(bool), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsChgZAChanged));
        public bool IsChgZA
        {
            get
            {
                return (bool)GetValue(IsChgZAProperty);
            }
            set
            {
                SetValue(IsChgZAProperty, value);
            }
        }
        private static void OnIsChgZAChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.IsChgZA = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==AUF===========
        public static readonly DependencyProperty AUFProperty = DependencyProperty.Register("AUF",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnAUFChanged));
        public string AUF
        {
            get
            {
                return (string)GetValue(AUFProperty);
            }
            set
            {
                SetValue(AUFProperty, value);
                OnAUFChg(value);
            }
        }
        private static void OnAUFChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.AUF = (string)e.NewValue;
            }
        }
        #endregion

        #region ==IsCheckKD===========
        public static readonly DependencyProperty IsCheckKDProperty = DependencyProperty.Register("IsCheckKD",
        typeof(bool), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsCheckKDChanged));
        public bool IsCheckKD
        {
            get
            {
                return (bool)GetValue(IsCheckKDProperty);
            }
            set
            {
                SetValue(IsCheckKDProperty, value);
            }
        }
        private static void OnIsCheckKDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.IsCheckKD = (bool)e.NewValue;
            }
        }
        #endregion


        #region ==IsCheckLS===========
        public static readonly DependencyProperty IsCheckLSProperty = DependencyProperty.Register("IsCheckLS",
        typeof(bool), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsCheckLSChanged));
        public bool IsCheckLS
        {
            get
            {
                return (bool)GetValue(IsCheckLSProperty);
            }
            set
            {
                SetValue(IsCheckLSProperty, value);
            }
        }
        private static void OnIsCheckLSChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.IsCheckLS = (bool)e.NewValue;
            }
        }
        #endregion
        #region ==FTVK===========
        public static readonly DependencyProperty FTVKProperty = DependencyProperty.Register("FTVK",
        typeof(bool), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnFTVKChanged));
        public bool FTVK
        {
            get
            {
                return (bool)GetValue(FTVKProperty);
            }
            set
            {
                SetValue(FTVKProperty, value);
                TMV.FTVK = value;
            }
        }
        private static void OnFTVKChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.FTVK = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsVV===========
        public static readonly DependencyProperty IsVVProperty = DependencyProperty.Register("IsVV",
        typeof(bool), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsVVChanged));
        public bool IsVV
        {
            get
            {
                return (bool)GetValue(IsVVProperty);
            }
            set
            {
                SetValue(IsVVProperty, value);
                if (MV == null)
                    return;
                TMV.IsVV = value;
            }
        }
        private static void OnIsVVChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.IsVV = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsOrder===========
        public static readonly DependencyProperty IsOrderProperty = DependencyProperty.Register("IsOrder",
        typeof(bool), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsOrderChanged));
        public bool IsOrder
        {
            get
            {
                return (bool)GetValue(IsOrderProperty);
            }
            set
            {
                SetValue(IsOrderProperty, value);
            }
        }
        private static void OnIsOrderChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.IsOrder = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==AUFART===========
        public static readonly DependencyProperty AUFARTProperty = DependencyProperty.Register("AUFART",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnAUFARTChanged));
        public string AUFART
        {
            get
            {
                return (string)GetValue(AUFARTProperty);
            }
            set
            {
                SetValue(AUFARTProperty, value);
                CheckEnv(value);
            }
        }
        private static void OnAUFARTChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.AUFART = (string)e.NewValue;
            }
        }
        #endregion

        #region ==dwVKK===========
        public static readonly DependencyProperty dwVKKProperty = DependencyProperty.Register("dwVKK",
        typeof(DataRow), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OndwVKKChanged));
        public DataRow dwVKK
        {
            get
            {
                return (DataRow)GetValue(dwVKKProperty);
            }
            set
            {
                SetValue(dwVKKProperty, value);
            }
        }
        private static void OndwVKKChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.dwVKK = (DataRow)e.NewValue;
            }
        }
        #endregion

        #region ==KUNDNR===========
        public static readonly DependencyProperty KUNDNRProperty = DependencyProperty.Register("KUNDNR",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnKUNDNRChanged));
        public string KUNDNR
        {
            get
            {
                return (string)GetValue(KUNDNRProperty);
            }
            set
            {
                SetValue(KUNDNRProperty, value);
                if (MV == null)
                    return;
            }
        }
        private static void OnKUNDNRChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.KUNDNR = (string)e.NewValue;
            }
        }
        #endregion

        #region ==SACHBE===========
        public static readonly DependencyProperty SACHBEProperty = DependencyProperty.Register("SACHBE",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnSACHBEChanged));
        public string SACHBE
        {
            get
            {
                return (string)GetValue(SACHBEProperty);
            }
            set
            {
                SetValue(SACHBEProperty, value);
                OnSACHBEChg(value);
                if (MV == null) return;
                TMV.VKKSACHBE = value;
            }
        }
        private static void OnSACHBEChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.SACHBE = (string)e.NewValue;
            }
        }
        #endregion

        #region ==LIEFSCH===========
        public static readonly DependencyProperty LIEFSCHProperty = DependencyProperty.Register("LIEFSCH",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnLIEFSCHChanged));
        public string LIEFSCH
        {
            get
            {
                return (string)GetValue(LIEFSCHProperty);
            }
            set
            {
                SetValue(LIEFSCHProperty, value);
            }
        }
        private static void OnLIEFSCHChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.LIEFSCH = (string)e.NewValue;
            }
        }
        #endregion

        #region ==SART===========
        public static readonly DependencyProperty SARTProperty = DependencyProperty.Register("SART",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnSARTChanged));
        public string SART
        {
            get
            {
                return (string)GetValue(SARTProperty);
            }
            set
            {
                SetValue(SARTProperty, value);
                OnSARTChg(value);
            }
        }
        private static void OnSARTChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.SART = (string)e.NewValue;
            }
        }
        #endregion

        #region ==VSPED===========
        public static readonly DependencyProperty VSPEDProperty = DependencyProperty.Register("VSPED",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVSPEDChanged));
        public string VSPED
        {
            get
            {
                return (string)GetValue(VSPEDProperty);
            }
            set
            {
                SetValue(VSPEDProperty, value);
                OnVSPEDChg(value);
            }
        }
        private static void OnVSPEDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.VSPED = (string)e.NewValue;
            }
        }
        #endregion

        #region ==LIEFBED===========
        public static readonly DependencyProperty LIEFBEDProperty = DependencyProperty.Register("LIEFBED",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnLIEFBEDChanged));
        public string LIEFBED
        {
            get
            {
                return (string)GetValue(LIEFBEDProperty);
            }
            set
            {
                SetValue(LIEFBEDProperty, value);
                if (!IsEdit)
                    return;
                TMV.VKKLIEFBED = value;

            }
        }
        private static void OnLIEFBEDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.LIEFBED = (string)e.NewValue;
            }
        }
        #endregion

        #region ==ZAHLBED===========
        public static readonly DependencyProperty ZAHLBEDProperty = DependencyProperty.Register("ZAHLBED",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnZAHLBEDChanged));
        public string ZAHLBED
        {
            get
            {
                return (string)GetValue(ZAHLBEDProperty);
            }
            set
            {
                SetValue(ZAHLBEDProperty, value);
                OnZAHLBEDChg(value);
            }
        }
        private static void OnZAHLBEDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.ZAHLBED = (string)e.NewValue;
            }
        }
        #endregion

        #region ==VKZAHLBED===========
        public static readonly DependencyProperty VKZAHLBEDProperty = DependencyProperty.Register("VKZAHLBED",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVKZAHLBEDChanged));
        public string VKZAHLBED
        {
            get
            {
                return (string)GetValue(VKZAHLBEDProperty);
            }
            set
            {
                SetValue(VKZAHLBEDProperty, value);

            }
        }
        private static void OnVKZAHLBEDChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.VKZAHLBED = (string)e.NewValue;
            }
        }
        #endregion

        #region ==KD06KEY===========
        public static readonly DependencyProperty KD06KEYProperty = DependencyProperty.Register("KD06KEY",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnKD06KEYChanged));
        public string KD06KEY
        {
            get
            {
                return (string)GetValue(KD06KEYProperty);
            }
            set
            {
                SetValue(KD06KEYProperty, value);

            }
        }
        private static void OnKD06KEYChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.KD06KEY = (string)e.NewValue;
            }
        }
        #endregion

        #region ==VB===========
        public static readonly DependencyProperty VBProperty = DependencyProperty.Register("VB",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVBChanged));
        public string VB
        {
            get
            {
                return (string)GetValue(VBProperty);
            }
            set
            {
                SetValue(VBProperty, value);
            }
        }
        private static void OnVBChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.VB = (string)e.NewValue;
                src.OnVBChg((string)e.NewValue);
            }
        }
        public virtual void OnVBChg(string value)
        {
            TMV.VKKVB = value; 
        }
        #endregion

        #region ==VG===========
        public static readonly DependencyProperty VGProperty = DependencyProperty.Register("VG",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVGChanged));
        public string VG
        {
            get
            {
                return (string)GetValue(VGProperty);
            }
            set
            {
                SetValue(VGProperty, value);
                if (IsEdit && dwMaster != null)
                {
                    TMV.VKKVG = value;
                }
                if (app.company != "TST")
                    OnVGChg(value);
            }
        }
        private static void OnVGChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.VG = (string)e.NewValue;
            }
        }
        public virtual void OnVGChg(string vg)
        {
            if (!IsEdit) return;
            string _KD06KEY = TMV.VKKKUNDNR + "   " + TMV.VKKVG;
            if (KD06KEY != _KD06KEY)
            {
                KD06KEY = _KD06KEY;
            }

        }
        #endregion

        #region ==KDSTA===========
        public static readonly DependencyProperty KDSTAProperty = DependencyProperty.Register("KDSTA",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnKDSTAChanged));
        public string KDSTA
        {
            get
            {
                return (string)GetValue(KDSTAProperty);
            }
            set
            {
                SetValue(KDSTAProperty, value);
            }
        }
        private static void OnKDSTAChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.KDSTA = (string)e.NewValue;
            }
        }
        #endregion

        #region ==VKKANSPRECH===========
        public static readonly DependencyProperty VKKANSPRECHProperty = DependencyProperty.Register("VKKANSPRECH",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVKKANSPRECHChanged));
        public string VKKANSPRECH
        {
            get
            {
                return (string)GetValue(VKKANSPRECHProperty);
            }
            set
            {
                SetValue(VKKANSPRECHProperty, value);
                if (!IsEdit)
                    return;
                TMV.VKKANSPRECH = value;
            }
        }
        private static void OnVKKANSPRECHChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.VKKANSPRECH = (string)e.NewValue;
            }
        }
        #endregion

        #region ==VKKHWAEHRSL===========
        public static readonly DependencyProperty VKKHWAEHRSLProperty = DependencyProperty.Register("VKKHWAEHRSL",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnVKKHWAEHRSLChanged));
        public string VKKHWAEHRSL
        {
            get
            {
                return (string)GetValue(VKKHWAEHRSLProperty);
            }
            set
            {
                SetValue(VKKHWAEHRSLProperty, value);
                if (IsEdit && dwMaster != null)
                {
                    dwMaster["VKKHWAEHRSL"] = value;
                }
            }
        }
        private static void OnVKKHWAEHRSLChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.VKKHWAEHRSL = (string)e.NewValue;
            }
        }
        #endregion

        #region ==WAEHRSL===========
        public static readonly DependencyProperty WAEHRSLProperty = DependencyProperty.Register("WAEHRSL",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnWAEHRSLChanged));
        public string WAEHRSL
        {
            get
            {
                return (string)GetValue(WAEHRSLProperty);
            }
            set
            {
                SetValue(WAEHRSLProperty, value);
            }
        }
        private static void OnWAEHRSLChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.WAEHRSL = (string)e.NewValue;
            }
        }
        #endregion

        #region ==KURS===========
        public static readonly DependencyProperty KURSProperty = DependencyProperty.Register("KURS",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnKURSChanged));
        public string KURS
        {
            get
            {
                return (string)GetValue(KURSProperty);
            }
            set
            {
                SetValue(KURSProperty, value);
                OnKURSChg(value);
            }
        }
        private static void OnKURSChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.KURS = (string)e.NewValue;
            }
        }
        #endregion

        #region ==WERT===========
        public static readonly DependencyProperty WERTProperty = DependencyProperty.Register("WERT",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnWERTChanged));
        public string WERT
        {
            get
            {
                return (string)GetValue(WERTProperty);
            }
            set
            {
                SetValue(WERTProperty, value);
                OnWERTChg();
            }
        }
        private static void OnWERTChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.WERT = (string)e.NewValue;
            }
        }
        #endregion

        #region ==KDBLOCK===========
        public static readonly DependencyProperty KDBLOCKProperty = DependencyProperty.Register("KDBLOCK",
        typeof(bool), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnKDBLOCKChanged));
        public bool KDBLOCK
        {
            get
            {
                return (bool)GetValue(KDBLOCKProperty);
            }
            set
            {
                SetValue(KDBLOCKProperty, value);
                OnKDBLOCKChg(value);
            }
        }
        private static void OnKDBLOCKChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.KDBLOCK = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsAUFConfirmed===========
        public static readonly DependencyProperty IsAUFConfirmedProperty = DependencyProperty.Register("IsAUFConfirmed",
        typeof(bool), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsAUFConfirmedChanged));
        public bool IsAUFConfirmed
        {
            get
            {
                return (bool)GetValue(IsAUFConfirmedProperty);
            }
            set
            {
                SetValue(IsAUFConfirmedProperty, value);
                OnIsAUFConfirmedChg(value);
            }
        }
        private static void OnIsAUFConfirmedChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.IsAUFConfirmed = (bool)e.NewValue;
            }
        }
        #endregion

        #region ==IsZoneWBFull===========
        public static readonly DependencyProperty IsZoneWBFullProperty = DependencyProperty.Register("IsZoneWBFull",
        typeof(bool), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsZoneWBFullChanged));
        public bool IsZoneWBFull
        {
            get
            {
                return (bool)GetValue(IsZoneWBFullProperty);
            }
            set
            {
                SetValue(IsZoneWBFullProperty, value);
                OnIsZoneWBFullChg(value);
            }
        }
        private static void OnIsZoneWBFullChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.IsZoneWBFull = (bool)e.NewValue;
            }
        }
        public void OnIsZoneWBFullChg(bool value)
        {
        }

        #endregion

     
        #region ==IsVKKChgApp===========
        public static readonly DependencyProperty IsVKKChgAppProperty = DependencyProperty.Register("IsVKKChgApp",
        typeof(bool), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnIsVKKChgAppChanged));
        public bool IsVKKChgApp
        {
            get
            {
                return (bool)GetValue(IsVKKChgAppProperty);
            }
            set
            {
                SetValue(IsVKKChgAppProperty, value);
            }
        }
        private static void OnIsVKKChgAppChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.IsVKKChgApp = (bool)e.NewValue;
                src.OnEVKKChgApp((bool)e.NewValue);
            }
        }
        #endregion
        #region ==LIEFNR===========
        public static readonly DependencyProperty LIEFNRProperty = DependencyProperty.Register("LIEFNR",
        typeof(string), typeof(UIVKKOPF),
        new FrameworkPropertyMetadata("", FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnLIEFNRChanged));
        public string LIEFNR
        {
            get
            {
                return (string)GetValue(LIEFNRProperty);
            }
            set
            {
                SetValue(LIEFNRProperty, value);
            }
        }
        private static void OnLIEFNRChanged(DependencyObject sender, DependencyPropertyChangedEventArgs e)
        {
            var src = sender as UIVKKOPF;
            if (src != null)
            {
                src.LIEFNR = (string)e.NewValue;
            }
        }
        #endregion  
    }
}
